#include <sched.h>
#include <unistd.h>
#include <monitor.h>
#include <QApplication>
#include <iostream>
#include <stdio.h>
#include <QTranslator>


int main(int argc, char *argv[])
{
    // 设置CPU亲和性到指定核心
    cpu_set_t cpuset;
    CPU_ZERO(&cpuset);
    int core_id = 0; // 修改此处为指定的核心编号
    CPU_SET(core_id, &cpuset);

    pid_t pid = getpid();
    if (sched_setaffinity(pid, sizeof(cpu_set_t), &cpuset) == -1)
    {
        perror("sched_setaffinity failed");
        return 1;
    }

    QApplication a(argc, argv);

    QTranslator trans;
    QString locale = QLocale::system().name();
    if(locale == "zh_CN")
    {
        if(trans.load(":/translations/gui_zh_CN.qm"))
        {
            a.installTranslator(&trans);
        }
    }
    if(locale == "bo_CN")
    {
        if(trans.load(":/translations/gui_bo_CN.qm"))
        {
            a.installTranslator(&trans);
        }
    }

    /**
     * @brief 监视器对象
     */
    Monitor m;

    QWindow *win = m.windowHandle();

    a.setActiveWindow(&m);
    m.show();

    return a.exec();
}
